package com.tandn.helpers;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.view.MotionEvent;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class MapOverlay extends Overlay
{
	private GeoPoint _geoPoint = null;
	private int _idDrawable = -1;
	private Context _context = null;

	public MapOverlay(Context context, GeoPoint point, int idDrawable)
	{
		_geoPoint = point;
		_idDrawable = idDrawable;
		_context = context;
	}

	@Override
	public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
			long when)
	{
		super.draw(canvas, mapView, shadow, when);
		/* translate the GeoPoint to the screen pixel */
		Point screenPoint = new Point();
		mapView.getProjection().toPixels(_geoPoint, screenPoint);
		/* Draw the image */
		if (_idDrawable != -1)
		{
			Bitmap bitmap = BitmapFactory.decodeResource(_context.getResources(), _idDrawable);
			canvas.drawBitmap(bitmap, screenPoint.x, screenPoint.y
					//- bitmap.getHeight()
					, null);
		}
		return true;
	}


	public GeoPoint getGeoPoint()
	{
		return _geoPoint;
	}
}
